#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() 
{
    vector<string> v;
    int n;
    cin >> n;
    v.resize(n);
    for(auto &str : v)
    {
        cin >> str;
    }
    bool lsort = true, csort = true;
    
    for(int i = 0;i < n;i++)
    {
        if(v[i - 1].size() > v[i].size())
        {
            lsort = false;//并非按长度排序
            break;
        }
    }

    for(int i = 1 ; i< n;i++)
    {
        if(v[i - 1] > v[i])
        {
            csort = false;//并非按字典排序
            break;
        }
    }
	
	//判断是哪种情况
    if(lsort && csort)
        cout << "both" << endl;
    else if(lsort)
        cout << "lengths" << endl;
    else if(csort)
        cout << "lexicographically" << endl;
    else
        cout << "none" << endl;
    return 0;
}

